package filter;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;

public class HeaderHttpRequestFilter implements HttpRequestFilter {

    @Override
    public void filter(FullHttpRequest fullRequest, ChannelHandlerContext ctx) {
        String token = fullRequest.headers().get("token");
        if(null != token && !"".equals(token)){
            fullRequest.headers().set("user","dd");
            System.out.println("filter-->请求携带token，使用user: dd");
        }else {
            fullRequest.headers().set("user","pp");
            System.out.println("filter-->请求没有携带token，使用默认user: pp");
        }
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
